<template>
  <div class="header">
    <div class="content-wrapper">
      <div class="avatar">
        <img width="64" height="64" :src="seller.avatar">
      </div>
      <div class="content">
        <div class="title">
          <span class="brand-icon"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">
          {{seller.description}} / {{seller.deliveryTime}}分钟送达
        </div>
        <div class="support" v-if="seller.supports">
          <span class="support-icon" :class="classMap[seller.supports[0].type]"></span>
          <span class="support-desc">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div class="support-count" v-if="seller.supports" @click="handleDetailShow">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wrapper" @click="handleDetailShow">
      <span class="bulletin-title"></span><span class="bulletin-desc">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img width="100%" height="100%" :src="seller.avatar">
    </div>
    <fade-animation>
      <div v-show="detailShow" class="detail">
        <div class="detail-wrapper clearfix">
          <div class="detail-main">
            <h1 class="main-title">{{seller.name}}</h1>
            <div class="star-wrapper">
              <v-star :size="48" :score="seller.score"></v-star>
            </div>
            <div class="title">
              <div class="line"></div>
              <div class="text">优惠信息</div>
              <div class="line"></div>
            </div>
            <ul class="support" v-if="seller.supports">
              <li class="support-item" v-for="item of seller.supports" :key="item.type">
                <span class="item-icon" :class="classMap[item.type]"></span><span class="item-desc">{{item.description}}</span>
              </li>
            </ul>
            <div class="title">
              <div class="line"></div>
              <div class="text">商家公告</div>
              <div class="line"></div>
            </div>
            <div class="bulletin">
              <p class="bulletin-content">{{seller.bulletin}}</p>
            </div>
          </div>
        </div>
        <div class="detail-close" @click="handleDetailClose">
          <i class="icon-close"></i>
        </div>
      </div>
    </fade-animation>
  </div>
</template>
<script>
import Star from 'components/star/Star'
import FadeAnimation from 'components/animation/FadeAnimation'
export default {
  name: 'Header',
  components: {
    'v-star': Star,
    FadeAnimation
  },
  props: {
    seller: Object
  },
  data () {
    return {
      classMap: [],
      detailShow: false
    }
  },
  methods: {
    handleDetailShow () {
      this.detailShow = true
    },
    handleDetailClose () {
      this.detailShow = false
    }
  },
  mounted () {
    this.classMap = ['decrease', 'discount', 'guarantee', 'invoice', 'special']
  }
}
</script>
<style lang="stylus" scoped>
  @import '~common/styles/varibles.styl'
  @import '~common/styles/mixins.styl'
  .header
    position relative
    overflow hidden
    color #fff
    background-color rgba(7,17,27,0.5)
    .content-wrapper
      position relative
      padding 24px 12px 18px 24px
      font-size 0
      .avatar
        display inline-block
        vertical-align top
        &>img
          border-radius 4px
      .content
        display inline-block
        vertical-align top
        padding-left 16px
        font-size 14px
        .title
          margin 2px 0 8px 0
          .brand-icon
            display inline-block
            width 30px
            height 18px
            bg-image('brand')
            background-size 30px 18px
            background-repeat no-repeat
          .name
            vertical-align top
            margin-left 6px
            line-height 18px
            font-size 16px
            font-weight bold
        .description
          font-size 12px
        .support
          margin 10px 0 2px 0
          .support-icon
            bg-image-size(12px, 12px)
            &.decrease
              bg-image('decrease_1')
            &.discount
              bg-image('discount_1')
            &.guarantee
              bg-image('guarantee_1')
            &.invoice
              bg-image('invoice_1')
            &.special
              bg-image('special_1')
          .support-desc
            vertical-align top
            margin-left 4px
            line-height 12px
            font-size 10px
      .support-count
        position absolute
        right 12px
        bottom 18px
        padding 0 8px
        height 24px
        line-height 24px
        background-color rgba(0,0,0,0.2)
        border-radius 20px
        text-align center
        .count
          vertical-align top
          font-size 10px
        .icon-keyboard_arrow_right
          margin-left 2px
          line-height 24px
          font-size 10px
    .bulletin-wrapper
      position relative
      padding 0 22px 0 12px
      height 28px
      line-height 28px
      // font-size 0
      background-color rgba(7,17,27,0.2)
      ellipsis()
      .bulletin-title
        bg-image-size(22px, 12px)
        bg-image('bulletin')
        margin-top 8px
      .bulletin-desc
        vertical-align top
        margin 0 4px
        font-size 10px
      .icon-keyboard_arrow_right
        position absolute
        top 9px
        right 12px
        font-size 10px
    .background
      z-index -1
      position absolute
      top 0
      left 0
      width 100%
      height 100%
      filter blur(10px)
    .detail
      z-index 100
      overflow auto
      position fixed
      top 0
      left 0
      width 100%
      height 100%
      background-color rgba(7,17,27,.8)
      .detail-wrapper
        width 100%
        min-height 100%
        .detail-main
          margin-top 64px
          padding-bottom 128px
          text-align center
          .star-wrapper
            margin-top 16px
            padding 2px 0
            text-align center
          .title
            display flex
            width 80%
            margin 28px auto 24px auto
            .line
              flex 1
              position relative
              top -6px
              border-bottom 1px solid rgba(255,255,255,0.2)
            .text
              padding 0 12px
          .support
            width 80%
            margin 0 auto
            text-align left
            .support-item
                padding 0 12px 12px 12px
                &:last-child
                  padding-bottom 0
                ellipsis()
                .item-icon
                  bg-image-size(16px, 16px)
                  &.decrease
                    bg-image('decrease_2')
                  &.discount
                    bg-image('discount_2')
                  &.guarantee
                    bg-image('guarantee_2')
                  &.invoice
                    bg-image('invoice_2')
                  &.special
                    bg-image('special_2')
                .item-desc
                  vertical-align top
                  margin-left 6px
                  line-height 16px
                  font-size 12px
          .bulletin
            width 80%
            margin 0 auto
            .bulletin-content
              padding 0 12px
              line-height 24px
              font-size 12px
              text-align left
      .detail-close
        position relative
        width 32px
        height 32px
        margin -78px auto 0 auto
        clear both
        font-size 32px
</style>
